From a7c7862e47a88382bcf97bd1e7f04de8b28aad2f Mon Sep 17 00:00:00 2001 From: justbur Date: Wed, 8 Jul 2015 16:08:03 -0400 Subject: [PATCH] Fix #21 --- which-key.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/which-key.el b/which-key.el index b8be10f1a23..1d93066c9ed 100644 --- a/which-key.el +++ b/which-key.el @@ -393,7 +393,8 @@ the maximum number of lines availabel in the target buffer." (defun which-key/populate-buffer (prefix-keys formatted-keys column-width sel-win-width) "Insert FORMATTED-STRINGS into which-key buffer, breaking after BUFFER-WIDTH." - (let* ((prefix-w-face (which-key/propertize-key prefix-keys)) + (let* ((vertical-mode (member which-key-side-window-location '(left right))) + (prefix-w-face (which-key/propertize-key prefix-keys)) (prefix-len (+ 2 (length (substring-no-properties prefix-w-face)))) (prefix-string (when which-key-show-prefix (if (eq which-key-show-prefix 'left) @@ -406,8 +407,11 @@ the maximum number of lines availabel in the target buffer." (if (eq which-key-show-prefix 'left) (- (cdr max-dims) prefix-len) (cdr max-dims)) 0)) - ;; the 3 leaves room for the ... possibly on the first page (remove for now) (n-columns (/ max-width-for-columns column-width)) ;; integer division + (n-columns (if vertical-mode + ;; use up vertical space first if possible + (min n-columns (ceiling (/ (float n-keys) max-height))) + n-columns)) (act-width (+ (* n-columns column-width) (if (eq which-key-show-prefix 'left) prefix-len 0))) ;; (avl-lines/page (which-key/available-lines)) -- 2.30.2